#!/bin/bash

Green_font_prefix="\033[32m"
Red_font_prefix="\033[31m"
Green_background_prefix="\033[42;37m"
Red_background_prefix="\033[41;37m"
Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"

function check_root() {
    [[ $EUID != 0 ]] && echo -e "${Error} 当前非ROOT账号(或没有ROOT权限)，无法继续操作，请更换ROOT账号或使用 ${Green_background_prefix}sudo su${Font_color_suffix} 命令获取临时ROOT权限（执行后可能会提示输入当前账号的密码）。" && exit 1
}

function neihe_chakan() {
    uname -a
}

function auto() {
    check_root
    while true; do
        echo && echo -e "${Green_font_prefix}       系统内核 一键脚本
   ${Green_font_prefix} ----------- Noob_Cfy 内核工具-----------
   ${Green_font_prefix}1. 查看系统内核
 
   ${Green_font_prefix}0. 退出脚本
  ———————————— ${Font_color_suffix}" && echo
        read -e -p " 请输入数字 [0-1]:" num
        case "$num" in
        1)
            neihe_chakan
            echo
            read -n 1 -s -r -p "按任意键返回菜单..."
            ;;
        0)
            exit 0
            ;;
        *)
            echo "请输入正确数字 [0-1]"
            ;;
        esac
    done
}

if [ $# -gt 0 ]; then
    if [ $1 == "install" ]; then
        install
    elif [ $1 == "start" ]; then
        start
    elif [ $1 == "stop" ]; then
        stop
    elif [ $1 == "update" ]; then
        update
    elif [ $1 == "uninstall" ]; then
        uninstall
    fi
else
    auto
fi
